package com.bite.common.config;

import com.bite.common.utils.MailUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.mail.MailProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSender;

@Configuration
@Slf4j
public class MailConfig {
    @Bean
    @ConditionalOnProperty(prefix = "spring.mail", name = "host")
    public MailUtil mailUtil(JavaMailSender javaMailSender, MailProperties mailProperties){
        log.info("注入MailUtil......");
        return new MailUtil(javaMailSender, mailProperties);
    }
}
